package org.tbwork.utility.httprr.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Provides some useful common process methods of URL<p> 
 * @author Tommy.Tang
 * @Date 2015-09-10
 */
public class UrlUtil {
 
	public static String getHostFromUrl(String url)
	{
		Pattern pattern = null;
		if(url.substring(url.length()>8?9:0).contains("/"))
			pattern = Pattern.compile("https?://.*/");
		else
			pattern = Pattern.compile("https?://.*");
		Matcher matcher = pattern.matcher(url);
		if(matcher.find())
			return matcher.group().replaceAll("https?:", "").replaceAll("/", "");
		else
			return "";
	}
	 
}
